﻿using Newtonsoft.Json;

namespace Communication.Lib.Mode
{
    public class DemoInfo : BaseInfo
    {
        public float Data { get; set; }

        /// <summary>
        /// 有效标记
        /// </summary>
        public byte Valid { get; set; }

        /// <summary>
        /// 状态，0：正常；1：故障
        /// </summary>
        [JsonIgnore]
        public bool IsNormal => (Valid & 1) == 0;

        /// <summary>
        ///数据有效性，0：无效；1：有效
        /// </summary>
        [JsonIgnore]
        public bool IsValid => (Valid & 2) == 2;

        public override string ToString() => string.Format("{0} {1}", IsValid ? Data.ToString("f1") : "-", IsNormal ? "" : "Error");
    }
}